<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center complainData_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub complainData_fd0_0'>
          <view class='flex flex-wrap align-center complainData_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  complainData_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='complainData_fd0_0_c1_c0'>投诉</text>
          </view>
          <view class='flex flex-wrap align-center justify-end complainData_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout complainData_flex_1">
        <view class='flex flex-wrap align-center'>
          <text class='complainData_fd1_0_c0'>请选择你想要投诉的类型</text>
          <text class='complainData_fd1_0_c1'>*</text>
        </view>
        <view class='flex flex-direction flex-wrap align-stretch complainData_fd1_1'>
          <benben-select-diy ref="showSelectPopup1703917733698" class-name='flex align-center flex-wrap'
            :items.sync="complainType" v-model="complain_id" default-type="aid" default-label="cate_name"
            :allow-cancel='false' type="radio" :disabled='false'>
            <template v-for='(item,key0) in complainType'>
              <view v-if="item.isSelected" class='flex align-center justify-center flex complainData_fd1_1_c0_c0'
                :key="key0" @tap="$refs.showSelectPopup1703917733698.tapHandle(key0)">
                <text class='complainData_fd1_1_c0_c0_c0'>{{item.cate_name}}</text>
              </view>
              <view v-else class='flex align-center justify-center flex complainData_fd1_1_c0_c1' :key="key0"
                @tap="$refs.showSelectPopup1703917733698.tapHandle(key0)">
                <text class='complainData_fd1_1_c0_c1_c0'>{{item.cate_name}}</text>
              </view>
            </template></benben-select-diy>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center complainData_flex_2">
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout complainData_flex_3">
        <view class='flex flex-wrap align-center'>
          <text class='complainData_fd3_0_c0'>投诉描述</text>
          <text class='complainData_fd3_0_c1'>（选填）</text>
        </view>
        <view class='flex flex-direction flex-wrap align-stretch'>
          <view class='flex flex-wrap complainData_fd3_1_c0'>
            <textarea class='flex complainData_input_fd3_1_c0' :placeholder="'提供更多信息，有助于投诉被快速处理～'" :maxlength="200"
              :show-num='true' placeholder-style="color:#999;font-size:28rpx" v-model="content" />
            <template>
              <view class='flex flex justify-end complainData_numberfd3_1_c0_c0'>
                <text>{{content.length}}</text>
                <text>/</text>
                <text>200</text>
              </view>
            </template>
          </view>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center complainData_flex_4">
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout complainData_flex_5">
        <view class='flex flex-wrap align-center'>
          <text class='complainData_fd5_0_c0'>图片证据</text>
          <text class='complainData_fd5_0_c1'>（选填）</text>
          <text class='complainData_fd5_0_c2'>最多三张</text>
        </view>
        <view class='flex flex-wrap align-center'>
          <benben-images-upload ref="benbenImagesUploadfd5_1_c0" :img-list.sync="img" :img-ids.sync="img_id"
            :maxlength="3">
            <template #content="{ num, maxlength, isShow, imgList }">
              <view class="flex flex-wrap align-start flex complainData_fd5_1_c0">

                <view v-for="(image, index) in imgList" :key="index"
                  class='flex position-relative complainData_fd5_1_c00'>
                  <text class='fu-iconfont2 position-absolute complainData_fd5_1_c000'
                    @tap.stop="$refs.benbenImagesUploadfd5_1_c0.delImage(index)">&#xE8E7;</text>
                  <image class='complainData_fd5_1_c001'
                    @tap.stop="$refs.benbenImagesUploadfd5_1_c0.previewImage(index)" mode="aspectFit" :src='image'>
                  </image>
                </view>

                <image class='complainData_fd5_1_c01' @tap.stop="$refs.benbenImagesUploadfd5_1_c0.manyChooseImage()"
                  v-if="isShow" mode="aspectFit" :src='STATIC_URL+"52.png"'></image>

              </view>
            </template>
          </benben-images-upload>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <view class="flex flex-wrap align-center justify-center benben-position-layout flex complainData_flex_6">
        <button class='complainData_fd6_0' @tap.stop="submitComplaintFunc()">提交</button>

      </view>
      <view :style="{height: '88rpx'}"></view>


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},


    data() {
      return {
        "complainType": [],
        "complain_id": "",
        "content": "",
        "img": [],
        "img_id": "",
        "type": "",
        "posts_id": "",
        "organizational_id": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        type,
        posts_id,
        organizational_id
      } = options
      if (type !== undefined) this.type = type
      if (posts_id !== undefined) this.posts_id = posts_id
      if (organizational_id !== undefined) this.organizational_id = organizational_id
      this.getComplainFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //获取投诉类型
      async getComplainFunc() {
        //请求方法
        //数据验证

        let datacomplainType = await this.$api.get(global.apiUrls.post657927e989b5d, {

        });

        if (datacomplainType.data.code != 1) {
          this.$message.info(datacomplainType.data.msg);
          return
        }
        let infocomplainType = datacomplainType.data;
        this.complainType = infocomplainType.data

      },
      //提交投诉
      async submitComplaintFunc() {
        if (!validate(this.complain_id, 'require')) {
          this.$message.info('请选择投诉类型');
          return false;
        }
        //请求方法
        //数据验证

        let data657928cbacf16 = await this.$api.post(global.apiUrls.post657928cbacf16, {
          type: this.type,
          content: this.content,
          images: this.img_id,
          postreportcate_id: this.complain_id,
          postquestion_id: this.posts_id,
          postoffice_id: this.organizational_id
        });

        if (data657928cbacf16.data.code != 1) {
          this.$message.info(data657928cbacf16.data.msg);
          return
        }



        uni.showToast({
          title: '提交成功',
          mask: true,
          icon: 'none',
          duration: 1500
        });
        setTimeout(() => {
          this.$urouter.navigateBack(1);
        }, 500)
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(255, 255, 255, 1);
    background-size: 100% auto;
  }

  .complainData_flex_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .complainData_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .complainData_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .complainData_fd0_0_c0 {
    width: 120rpx;
  }

  .complainData_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .complainData_flex_1 {
    padding: 32rpx 32rpx 32rpx 32rpx;
  }

  .complainData_fd1_1_c0_c1_c0 {
    color: #666666;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 28rpx;
  }

  .complainData_fd1_1_c0_c1 {
    background: rgba(248, 248, 248, 1);
    width: 200rpx;
    height: 64rpx;
    border-radius: 8rpx;
    margin-right: 16rpx;
    margin-top: 16rpx;
    background-size: 100% auto;
  }

  .complainData_fd1_1_c0_c0_c0 {
    color: #FFFFFF;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 28rpx;
  }

  .complainData_fd1_1_c0_c0 {
    background: rgba(100, 80, 235, 1);
    width: 200rpx;
    height: 64rpx;
    border-radius: 8rpx;
    margin-right: 16rpx;
    margin-top: 16rpx;
    background-size: 100% auto;
  }

  .complainData_fd1_1 {
    margin: 24rpx 0rpx 0rpx 0rpx;
    width: 686rpx;
  }

  .complainData_fd1_0_c1 {
    color: #E22F2F;
    font-size: 32rpx;
    font-weight: 500;
    line-height: 32rpx;
  }

  .complainData_fd1_0_c0 {
    color: rgba(26, 26, 26, 1);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 32rpx;
  }

  .complainData_flex_2 {
    background: rgba(248, 248, 248, 1);
    height: 20rpx;
    background-size: 100% auto;
  }

  .complainData_flex_3 {
    padding: 32rpx;
  }

  .complainData_numberfd3_1_c0_c0 {
    width: 100%;
    font-size: 24rpx;
    color: rgba(153, 153, 153, 1);
    line-height: 46rpx;
    font-weight: 400;
  }

  .complainData_input_fd3_1_c0 {
    width: 100%;
    height: 140rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #333;
    white-space: pre-wrap;
  }

  .complainData_fd3_1_c0 {
    background: rgba(255, 255, 255, 1);
    border-radius: 10rpx 10rpx 10rpx 10rpx;
    padding: 10rpx 0rpx 10rpx 0rpx;
    margin: 22rpx 0rpx 0rpx 0rpx;
  }

  .complainData_fd3_0_c1 {
    color: #999999;
    font-size: 24rpx;
    font-weight: 500;
    line-height: 32rpx;
  }

  .complainData_fd3_0_c0 {
    color: rgba(26, 26, 26, 1);
    font-size: 24rpx;
    font-weight: 500;
    line-height: 32rpx;
  }

  .complainData_flex_4 {
    background: rgba(248, 248, 248, 1);
    height: 20rpx;
    background-size: 100% auto;
  }

  .complainData_flex_5 {
    padding: 32rpx 32rpx 0rpx 32rpx;
  }

  .complainData_fd5_1_c01 {
    width: 160rpx;
    height: 160rpx;
    margin: 0rpx 24rpx 24rpx 0rpx;
  }

  .complainData_fd5_1_c001 {
    width: 160rpx;
    height: 160rpx;
  }

  .complainData_fd5_1_c000 {
    top: 0rpx;
    right: 0rpx;
    z-index: 10;
    color: #ff5536;
  }

  .complainData_fd5_1_c00 {
    margin: 0rpx 24rpx 24rpx 0rpx;
  }

  .complainData_fd5_1_c0 {
    padding: 24rpx 0rpx 0rpx 0rpx;
  }

  .complainData_fd5_0_c2 {
    color: #999999;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 32rpx;
    margin: 0rpx 0rpx 0rpx auto;
  }

  .complainData_fd5_0_c1 {
    color: #999999;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .complainData_fd5_0_c0 {
    color: rgba(26, 26, 26, 1);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 32rpx;
  }

  .complainData_flex_6 {
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(48rpx + var(--window-bottom));
  }

  .complainData_fd6_0 {
    background: rgba(100, 80, 235, 1);
    border-radius: 44rpx;
    width: 686rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
  }
</style>
